package com.memory.demo.Controller;
import com.memory.demo.service.AcceptimageService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
@RestController
public class AcceptController {

    @Resource
    private AcceptimageService acceptimageService;

    @PutMapping("/acceptimages/{id}")
    @CrossOrigin
    public String acceptimage(@PathVariable("id") int id, String text, MultipartFile image, HttpServletRequest request) throws IOException {
        System.out.println(text);
        if (image != null) {
            acceptimageService.singleFileUpload(image);
        }
        return "AMD yES";
    }

}
